/**
 * Created with JetBrains WebStorm.
 * User: Administrator
 * Date: 13-6-6
 * Time: 上午10:53
 * To change this template use File | Settings | File Templates.
 */

Ext.define('cloud.view.articlecategory.ArticleCategory', {
    extend: 'Ext.navigation.View',
    xtype: 'articlecategory',
    config: {
      //  defaultBackButtonText: '返回',
        items: [
            {
                xtype: 'container',
                layout: 'hbox',
                title: '资讯分类',
                items: [
                    {
                        xtype: 'toolbar',
                        docked: 'top',
                        items: [
                            {
                                xtype: 'textfield',
                                id: 'articlecategory_search',
                                name: 'articlecategory_search',
                                style: 'center',
                                placeHolder: '请输入分类名称'
                            }
                        ]
                    },
                    {
                        xtype: 'list',
                        id: 'articlecategorySelect',
                        flex: 1,
                        store: 'ArticleCategoryStore',
                        pressedCls: false,
                        selectedCls: false,
                        cls: 'x-list2',
                        onItemDisclosure: true,
                        emptyText: '还未添加资讯分类信息',
                        itemTpl: [
                            '<div class="listIcon">' +
                                '<tpl if="iconUrl">' +
                                    '<img src="{iconUrl}" />' +
                                '<tpl else>'+
                                '<img src="resources/images/null.png" />' +
                                '</tpl>'+
                            '</div>'+
                            '<div class="listConten">' + '<div class="listName">{name}</div>' +
                            '<span>排序：{display}</span>  ' +
                            '<span>更新时间:{[Ext.Date.format(new Date(parseInt(values.lasttime) * 1000), "Y-m-d H:i")]}</span>  ' +
                            ' </div> '
                        ].join(''),
                        listeners: {
                            initialize: function () {
                                var store = Ext.getStore('ArticleCategoryStore')
                                store.getProxy().setExtraParam('cadid', localStorage.getItem('cadid'));
                                store.load({params: {cadid: localStorage.getItem('cadid')}})

                            }
                        },
                        plugins: [
                            {
                                xclass: 'Ext.plugin.PullRefresh',
                                pullRefreshText: '下拉可以更新',
                                releaseRefreshText: '松开开始更新',
                                style: 'top:12px',
                                loadingText: '正在刷新……',
                                refreshFn: function (loaded, arguments) {
                                    //  loaded.getList().getStore().getProxy().setExtraParam('cadid', localStorage.getItem('cadid')); //设置proxy参数
                                    loaded.getList().getStore().loadPage(1, {
                                        callback: function (record, operation, success) {
                                            Ext.Viewport.unmask();
                                        }, scope: this });
                                }
                            },
                            {
                                xclass: 'Ext.plugin.ListPaging',
                                loadMoreText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">点击加载更多。。。。</h2>',
                                noMoreRecordsText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">没有更多条记录了</h2>',
                                autoPaging: false //设置为TRUE将自动触发
                            }
                        ]

                    },
                    {
                        xtype: 'toolbar',
                        id: 'articleCategory_toolbar',
                        docked: 'bottom',
                        layout: {
                            type: 'hbox',
                            pack: 'center'
                        },
                        items: [
                            {
                                xtype: 'button',
                                id: 'articlecategory_btn_add',
                                cls: 'x-button2',
                                iconMask: true,
                                text: '添加'
                            }
                        ]
                    }
                ]
            }
        ]
    }
});
